package com.java.exer_blackjack;

/**
 * @author shkstart
 * @create 2021-01-13 15:18
 */
public class Poker implements Comparable {
    //0-3  代表4种花色
    private int type;
    //1-13  代表牌面数值
    private int num;

    public Poker(int type, int num) {
        //this 预支对象
        this.type = 0;
        this.num = 1;

        //修正
        if (this.type < 0 || this.type > 3 || this.num > 13 || this.num < 1) {
            return;
        }
        this.type = type;
        this.num = num;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    @Override
    public String toString() {
        String[] type = {"♠", "♥", "♣", "♦"};
        String[] point = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
        return type[this.type] + point[this.num - 1];
    }

    @Override
    public int compareTo(Object o) {
        if (o == null) {
            return -1;
        }
        if (!(o instanceof Poker)) {
            return -1;
        }
        Poker poker = (Poker) o;

        if (Math.random() > 0.5) {
            return 1;
        }
        return -1;
    }
}
